﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using PAT.Entities;
using PAT.Data;

#endregion

namespace PAT.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="PatGrupoCatalogoProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class PatGrupoCatalogoProviderBaseCore : EntityProviderBase<PAT.Entities.PatGrupoCatalogo, PAT.Entities.PatGrupoCatalogoKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByIdItemInventarioFromPatItemGrupo
		
		/// <summary>
		///		Gets PAT_GRUPO_CATALOGO objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_ITEM_GRUPO table. Table PAT_GRUPO_CATALOGO is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_ITEM_GRUPO table.
		/// </summary>
		/// <param name="_idItemInventario"></param>
		/// <returns>Returns a typed collection of PatGrupoCatalogo objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdItemInventarioFromPatItemGrupo(System.Int32 _idItemInventario)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatItemGrupo(null,_idItemInventario, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatGrupoCatalogo objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_ITEM_GRUPO table. Table PAT_GRUPO_CATALOGO is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_ITEM_GRUPO table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatGrupoCatalogo objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdItemInventarioFromPatItemGrupo(System.Int32 _idItemInventario, int start, int pageLength)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatItemGrupo(null, _idItemInventario, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_ITEM_GRUPO table. Table PAT_GRUPO_CATALOGO is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_ITEM_GRUPO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdItemInventarioFromPatItemGrupo(TransactionManager transactionManager, System.Int32 _idItemInventario)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatItemGrupo(transactionManager, _idItemInventario, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_ITEM_GRUPO table. Table PAT_GRUPO_CATALOGO is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_ITEM_GRUPO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemInventario"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdItemInventarioFromPatItemGrupo(TransactionManager transactionManager, System.Int32 _idItemInventario,int start, int pageLength)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatItemGrupo(transactionManager, _idItemInventario, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_ITEM_GRUPO table. Table PAT_GRUPO_CATALOGO is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_ITEM_GRUPO table.
		/// </summary>
		/// <param name="_idItemInventario"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdItemInventarioFromPatItemGrupo(System.Int32 _idItemInventario,int start, int pageLength, out int count)
		{
			
			return GetByIdItemInventarioFromPatItemGrupo(null, _idItemInventario, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_GRUPO_CATALOGO objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_ITEM_GRUPO table. Table PAT_GRUPO_CATALOGO is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_ITEM_GRUPO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatGrupoCatalogo objects.</returns>
		public abstract TList<PatGrupoCatalogo> GetByIdItemInventarioFromPatItemGrupo(TransactionManager transactionManager,System.Int32 _idItemInventario, int start, int pageLength, out int count);
		
		#endregion GetByIdItemInventarioFromPatItemGrupo
		
		#region GetByIdKitFromPatMantenimientoProgramado
		
		/// <summary>
		///		Gets PAT_GRUPO_CATALOGO objects from the datasource by ID_KIT in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_GRUPO_CATALOGO is related to table PAT_KIT
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="_idKit"></param>
		/// <returns>Returns a typed collection of PatGrupoCatalogo objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdKitFromPatMantenimientoProgramado(System.Int32 _idKit)
		{
			int count = -1;
			return GetByIdKitFromPatMantenimientoProgramado(null,_idKit, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatGrupoCatalogo objects from the datasource by ID_KIT in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_GRUPO_CATALOGO is related to table PAT_KIT
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idKit"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatGrupoCatalogo objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdKitFromPatMantenimientoProgramado(System.Int32 _idKit, int start, int pageLength)
		{
			int count = -1;
			return GetByIdKitFromPatMantenimientoProgramado(null, _idKit, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_KIT in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_GRUPO_CATALOGO is related to table PAT_KIT
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idKit"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdKitFromPatMantenimientoProgramado(TransactionManager transactionManager, System.Int32 _idKit)
		{
			int count = -1;
			return GetByIdKitFromPatMantenimientoProgramado(transactionManager, _idKit, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_KIT in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_GRUPO_CATALOGO is related to table PAT_KIT
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idKit"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdKitFromPatMantenimientoProgramado(TransactionManager transactionManager, System.Int32 _idKit,int start, int pageLength)
		{
			int count = -1;
			return GetByIdKitFromPatMantenimientoProgramado(transactionManager, _idKit, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_KIT in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_GRUPO_CATALOGO is related to table PAT_KIT
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="_idKit"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdKitFromPatMantenimientoProgramado(System.Int32 _idKit,int start, int pageLength, out int count)
		{
			
			return GetByIdKitFromPatMantenimientoProgramado(null, _idKit, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_GRUPO_CATALOGO objects from the datasource by ID_KIT in the
		///		PAT_MANTENIMIENTO_PROGRAMADO table. Table PAT_GRUPO_CATALOGO is related to table PAT_KIT
		///		through the (M:N) relationship defined in the PAT_MANTENIMIENTO_PROGRAMADO table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idKit"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatGrupoCatalogo objects.</returns>
		public abstract TList<PatGrupoCatalogo> GetByIdKitFromPatMantenimientoProgramado(TransactionManager transactionManager,System.Int32 _idKit, int start, int pageLength, out int count);
		
		#endregion GetByIdKitFromPatMantenimientoProgramado
		
		#region GetByIdOperacionFromPatTiempoTaller
		
		/// <summary>
		///		Gets PAT_GRUPO_CATALOGO objects from the datasource by ID_OPERACION in the
		///		PAT_TIEMPO_TALLER table. Table PAT_GRUPO_CATALOGO is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_TIEMPO_TALLER table.
		/// </summary>
		/// <param name="_idOperacion"></param>
		/// <returns>Returns a typed collection of PatGrupoCatalogo objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdOperacionFromPatTiempoTaller(System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdOperacionFromPatTiempoTaller(null,_idOperacion, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatGrupoCatalogo objects from the datasource by ID_OPERACION in the
		///		PAT_TIEMPO_TALLER table. Table PAT_GRUPO_CATALOGO is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_TIEMPO_TALLER table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatGrupoCatalogo objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdOperacionFromPatTiempoTaller(System.Int32 _idOperacion, int start, int pageLength)
		{
			int count = -1;
			return GetByIdOperacionFromPatTiempoTaller(null, _idOperacion, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_OPERACION in the
		///		PAT_TIEMPO_TALLER table. Table PAT_GRUPO_CATALOGO is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_TIEMPO_TALLER table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdOperacionFromPatTiempoTaller(TransactionManager transactionManager, System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdOperacionFromPatTiempoTaller(transactionManager, _idOperacion, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_OPERACION in the
		///		PAT_TIEMPO_TALLER table. Table PAT_GRUPO_CATALOGO is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_TIEMPO_TALLER table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdOperacionFromPatTiempoTaller(TransactionManager transactionManager, System.Int32 _idOperacion,int start, int pageLength)
		{
			int count = -1;
			return GetByIdOperacionFromPatTiempoTaller(transactionManager, _idOperacion, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatGrupoCatalogo objects from the datasource by ID_OPERACION in the
		///		PAT_TIEMPO_TALLER table. Table PAT_GRUPO_CATALOGO is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_TIEMPO_TALLER table.
		/// </summary>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_GRUPO_CATALOGO objects.</returns>
		public TList<PatGrupoCatalogo> GetByIdOperacionFromPatTiempoTaller(System.Int32 _idOperacion,int start, int pageLength, out int count)
		{
			
			return GetByIdOperacionFromPatTiempoTaller(null, _idOperacion, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_GRUPO_CATALOGO objects from the datasource by ID_OPERACION in the
		///		PAT_TIEMPO_TALLER table. Table PAT_GRUPO_CATALOGO is related to table PAT_TEMPARIO
		///		through the (M:N) relationship defined in the PAT_TIEMPO_TALLER table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatGrupoCatalogo objects.</returns>
		public abstract TList<PatGrupoCatalogo> GetByIdOperacionFromPatTiempoTaller(TransactionManager transactionManager,System.Int32 _idOperacion, int start, int pageLength, out int count);
		
		#endregion GetByIdOperacionFromPatTiempoTaller
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, PAT.Entities.PatGrupoCatalogoKey key)
		{
			return Delete(transactionManager, key.IdGrupoCatalogo);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_idGrupoCatalogo">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int16 _idGrupoCatalogo)
		{
			return Delete(null, _idGrupoCatalogo);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override PAT.Entities.PatGrupoCatalogo Get(TransactionManager transactionManager, PAT.Entities.PatGrupoCatalogoKey key, int start, int pageLength)
		{
			return GetByIdGrupoCatalogo(transactionManager, key.IdGrupoCatalogo, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_PAT_GRUPO_CATALOGO index.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatGrupoCatalogo"/> class.</returns>
		public PAT.Entities.PatGrupoCatalogo GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(null,_idGrupoCatalogo, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_GRUPO_CATALOGO index.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatGrupoCatalogo"/> class.</returns>
		public PAT.Entities.PatGrupoCatalogo GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo, int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(null, _idGrupoCatalogo, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_GRUPO_CATALOGO index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatGrupoCatalogo"/> class.</returns>
		public PAT.Entities.PatGrupoCatalogo GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(transactionManager, _idGrupoCatalogo, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_GRUPO_CATALOGO index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatGrupoCatalogo"/> class.</returns>
		public PAT.Entities.PatGrupoCatalogo GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(transactionManager, _idGrupoCatalogo, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_GRUPO_CATALOGO index.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatGrupoCatalogo"/> class.</returns>
		public PAT.Entities.PatGrupoCatalogo GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo, int start, int pageLength, out int count)
		{
			return GetByIdGrupoCatalogo(null, _idGrupoCatalogo, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_GRUPO_CATALOGO index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatGrupoCatalogo"/> class.</returns>
		public abstract PAT.Entities.PatGrupoCatalogo GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;PatGrupoCatalogo&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;PatGrupoCatalogo&gt;"/></returns>
		public static TList<PatGrupoCatalogo> Fill(IDataReader reader, TList<PatGrupoCatalogo> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				PAT.Entities.PatGrupoCatalogo c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("PatGrupoCatalogo")
					.Append("|").Append((System.Int16)reader[((int)PatGrupoCatalogoColumn.IdGrupoCatalogo - 1)]).ToString();
					c = EntityManager.LocateOrCreate<PatGrupoCatalogo>(
					key.ToString(), // EntityTrackingKey
					"PatGrupoCatalogo",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new PAT.Entities.PatGrupoCatalogo();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.IdGrupoCatalogo = (System.Int16)reader[((int)PatGrupoCatalogoColumn.IdGrupoCatalogo - 1)];
					c.DescripcionGrupoCatalogo = (System.String)reader[((int)PatGrupoCatalogoColumn.DescripcionGrupoCatalogo - 1)];
					c.Activo = (System.Boolean)reader[((int)PatGrupoCatalogoColumn.Activo - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatGrupoCatalogo"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatGrupoCatalogo"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, PAT.Entities.PatGrupoCatalogo entity)
		{
			if (!reader.Read()) return;
			
			entity.IdGrupoCatalogo = (System.Int16)reader[((int)PatGrupoCatalogoColumn.IdGrupoCatalogo - 1)];
			entity.DescripcionGrupoCatalogo = (System.String)reader[((int)PatGrupoCatalogoColumn.DescripcionGrupoCatalogo - 1)];
			entity.Activo = (System.Boolean)reader[((int)PatGrupoCatalogoColumn.Activo - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatGrupoCatalogo"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatGrupoCatalogo"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, PAT.Entities.PatGrupoCatalogo entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IdGrupoCatalogo = (System.Int16)dataRow["ID_GRUPO_CATALOGO"];
			entity.DescripcionGrupoCatalogo = (System.String)dataRow["DESCRIPCION_GRUPO_CATALOGO"];
			entity.Activo = (System.Boolean)dataRow["ACTIVO"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatGrupoCatalogo"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">PAT.Entities.PatGrupoCatalogo Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, PAT.Entities.PatGrupoCatalogo entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByIdGrupoCatalogo methods when available
			
			#region PatKitCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatKit>|PatKitCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatKitCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatKitCollection = DataRepository.PatKitProvider.GetByIdGrupoCatalogo(transactionManager, entity.IdGrupoCatalogo);

				if (deep && entity.PatKitCollection.Count > 0)
				{
					deepHandles.Add("PatKitCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatKit>) DataRepository.PatKitProvider.DeepLoad,
						new object[] { transactionManager, entity.PatKitCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region IdOperacionPatTemparioCollection_From_PatTiempoTaller
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatTempario>|IdOperacionPatTemparioCollection_From_PatTiempoTaller", deepLoadType, innerList))
			{
				entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller = DataRepository.PatTemparioProvider.GetByIdGrupoCatalogoFromPatTiempoTaller(transactionManager, entity.IdGrupoCatalogo);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdOperacionPatTemparioCollection_From_PatTiempoTaller' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller != null)
				{
					deepHandles.Add("IdOperacionPatTemparioCollection_From_PatTiempoTaller",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatTempario >) DataRepository.PatTemparioProvider.DeepLoad,
						new object[] { transactionManager, entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region PatTiempoTallerCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatTiempoTaller>|PatTiempoTallerCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatTiempoTallerCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatTiempoTallerCollection = DataRepository.PatTiempoTallerProvider.GetByIdGrupoCatalogo(transactionManager, entity.IdGrupoCatalogo);

				if (deep && entity.PatTiempoTallerCollection.Count > 0)
				{
					deepHandles.Add("PatTiempoTallerCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatTiempoTaller>) DataRepository.PatTiempoTallerProvider.DeepLoad,
						new object[] { transactionManager, entity.PatTiempoTallerCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PatItemGrupoCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatItemGrupo>|PatItemGrupoCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatItemGrupoCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatItemGrupoCollection = DataRepository.PatItemGrupoProvider.GetByIdGrupoCatalogo(transactionManager, entity.IdGrupoCatalogo);

				if (deep && entity.PatItemGrupoCollection.Count > 0)
				{
					deepHandles.Add("PatItemGrupoCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatItemGrupo>) DataRepository.PatItemGrupoProvider.DeepLoad,
						new object[] { transactionManager, entity.PatItemGrupoCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatItemInventario>|IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo", deepLoadType, innerList))
			{
				entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo = DataRepository.PatItemInventarioProvider.GetByIdGrupoCatalogoFromPatItemGrupo(transactionManager, entity.IdGrupoCatalogo);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo != null)
				{
					deepHandles.Add("IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatItemInventario >) DataRepository.PatItemInventarioProvider.DeepLoad,
						new object[] { transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region IdKitPatKitCollection_From_PatMantenimientoProgramado
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatKit>|IdKitPatKitCollection_From_PatMantenimientoProgramado", deepLoadType, innerList))
			{
				entity.IdKitPatKitCollection_From_PatMantenimientoProgramado = DataRepository.PatKitProvider.GetByIdGrupoCatalogoFromPatMantenimientoProgramado(transactionManager, entity.IdGrupoCatalogo);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdKitPatKitCollection_From_PatMantenimientoProgramado' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdKitPatKitCollection_From_PatMantenimientoProgramado != null)
				{
					deepHandles.Add("IdKitPatKitCollection_From_PatMantenimientoProgramado",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatKit >) DataRepository.PatKitProvider.DeepLoad,
						new object[] { transactionManager, entity.IdKitPatKitCollection_From_PatMantenimientoProgramado, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region PatMantenimientoProgramadoCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatMantenimientoProgramado>|PatMantenimientoProgramadoCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatMantenimientoProgramadoCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatMantenimientoProgramadoCollection = DataRepository.PatMantenimientoProgramadoProvider.GetByIdGrupoCatalogo(transactionManager, entity.IdGrupoCatalogo);

				if (deep && entity.PatMantenimientoProgramadoCollection.Count > 0)
				{
					deepHandles.Add("PatMantenimientoProgramadoCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatMantenimientoProgramado>) DataRepository.PatMantenimientoProgramadoProvider.DeepLoad,
						new object[] { transactionManager, entity.PatMantenimientoProgramadoCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PatCatalogoVehiculoCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatCatalogoVehiculo>|PatCatalogoVehiculoCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatCatalogoVehiculoCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatCatalogoVehiculoCollection = DataRepository.PatCatalogoVehiculoProvider.GetByIdGrupoCatalogo(transactionManager, entity.IdGrupoCatalogo);

				if (deep && entity.PatCatalogoVehiculoCollection.Count > 0)
				{
					deepHandles.Add("PatCatalogoVehiculoCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatCatalogoVehiculo>) DataRepository.PatCatalogoVehiculoProvider.DeepLoad,
						new object[] { transactionManager, entity.PatCatalogoVehiculoCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the PAT.Entities.PatGrupoCatalogo object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">PAT.Entities.PatGrupoCatalogo instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">PAT.Entities.PatGrupoCatalogo Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, PAT.Entities.PatGrupoCatalogo entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();

			#region IdOperacionPatTemparioCollection_From_PatTiempoTaller>
			if (CanDeepSave(entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller, "List<PatTempario>|IdOperacionPatTemparioCollection_From_PatTiempoTaller", deepSaveType, innerList))
			{
				if (entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller.Count > 0 || entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller.DeletedItems.Count > 0)
				{
					DataRepository.PatTemparioProvider.Save(transactionManager, entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller); 
					deepHandles.Add("IdOperacionPatTemparioCollection_From_PatTiempoTaller",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatTempario>) DataRepository.PatTemparioProvider.DeepSave,
						new object[] { transactionManager, entity.IdOperacionPatTemparioCollection_From_PatTiempoTaller, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo>
			if (CanDeepSave(entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo, "List<PatItemInventario>|IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo", deepSaveType, innerList))
			{
				if (entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo.Count > 0 || entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo.DeletedItems.Count > 0)
				{
					DataRepository.PatItemInventarioProvider.Save(transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo); 
					deepHandles.Add("IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatItemInventario>) DataRepository.PatItemInventarioProvider.DeepSave,
						new object[] { transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region IdKitPatKitCollection_From_PatMantenimientoProgramado>
			if (CanDeepSave(entity.IdKitPatKitCollection_From_PatMantenimientoProgramado, "List<PatKit>|IdKitPatKitCollection_From_PatMantenimientoProgramado", deepSaveType, innerList))
			{
				if (entity.IdKitPatKitCollection_From_PatMantenimientoProgramado.Count > 0 || entity.IdKitPatKitCollection_From_PatMantenimientoProgramado.DeletedItems.Count > 0)
				{
					DataRepository.PatKitProvider.Save(transactionManager, entity.IdKitPatKitCollection_From_PatMantenimientoProgramado); 
					deepHandles.Add("IdKitPatKitCollection_From_PatMantenimientoProgramado",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatKit>) DataRepository.PatKitProvider.DeepSave,
						new object[] { transactionManager, entity.IdKitPatKitCollection_From_PatMantenimientoProgramado, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 
	
			#region List<PatKit>
				if (CanDeepSave(entity.PatKitCollection, "List<PatKit>|PatKitCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatKit child in entity.PatKitCollection)
					{
						if(child.IdGrupoCatalogoSource != null)
						{
							child.IdGrupoCatalogo = child.IdGrupoCatalogoSource.IdGrupoCatalogo;
						}
						else
						{
							child.IdGrupoCatalogo = entity.IdGrupoCatalogo;
						}

					}

					if (entity.PatKitCollection.Count > 0 || entity.PatKitCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatKitProvider.Save(transactionManager, entity.PatKitCollection);
						
						deepHandles.Add("PatKitCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatKit >) DataRepository.PatKitProvider.DeepSave,
							new object[] { transactionManager, entity.PatKitCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatTiempoTaller>
				if (CanDeepSave(entity.PatTiempoTallerCollection, "List<PatTiempoTaller>|PatTiempoTallerCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatTiempoTaller child in entity.PatTiempoTallerCollection)
					{
						if(child.IdGrupoCatalogoSource != null)
						{
								child.IdGrupoCatalogo = child.IdGrupoCatalogoSource.IdGrupoCatalogo;
						}

						if(child.IdOperacionSource != null)
						{
								child.IdOperacion = child.IdOperacionSource.IdOperacion;
						}

					}

					if (entity.PatTiempoTallerCollection.Count > 0 || entity.PatTiempoTallerCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatTiempoTallerProvider.Save(transactionManager, entity.PatTiempoTallerCollection);
						
						deepHandles.Add("PatTiempoTallerCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatTiempoTaller >) DataRepository.PatTiempoTallerProvider.DeepSave,
							new object[] { transactionManager, entity.PatTiempoTallerCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatItemGrupo>
				if (CanDeepSave(entity.PatItemGrupoCollection, "List<PatItemGrupo>|PatItemGrupoCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatItemGrupo child in entity.PatItemGrupoCollection)
					{
						if(child.IdGrupoCatalogoSource != null)
						{
								child.IdGrupoCatalogo = child.IdGrupoCatalogoSource.IdGrupoCatalogo;
						}

						if(child.IdItemInventarioSource != null)
						{
								child.IdItemInventario = child.IdItemInventarioSource.IdItemInventario;
						}

					}

					if (entity.PatItemGrupoCollection.Count > 0 || entity.PatItemGrupoCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatItemGrupoProvider.Save(transactionManager, entity.PatItemGrupoCollection);
						
						deepHandles.Add("PatItemGrupoCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatItemGrupo >) DataRepository.PatItemGrupoProvider.DeepSave,
							new object[] { transactionManager, entity.PatItemGrupoCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatMantenimientoProgramado>
				if (CanDeepSave(entity.PatMantenimientoProgramadoCollection, "List<PatMantenimientoProgramado>|PatMantenimientoProgramadoCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatMantenimientoProgramado child in entity.PatMantenimientoProgramadoCollection)
					{
						if(child.IdGrupoCatalogoSource != null)
						{
								child.IdGrupoCatalogo = child.IdGrupoCatalogoSource.IdGrupoCatalogo;
						}

						if(child.IdKitSource != null)
						{
								child.IdKit = child.IdKitSource.IdKit;
						}

					}

					if (entity.PatMantenimientoProgramadoCollection.Count > 0 || entity.PatMantenimientoProgramadoCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatMantenimientoProgramadoProvider.Save(transactionManager, entity.PatMantenimientoProgramadoCollection);
						
						deepHandles.Add("PatMantenimientoProgramadoCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatMantenimientoProgramado >) DataRepository.PatMantenimientoProgramadoProvider.DeepSave,
							new object[] { transactionManager, entity.PatMantenimientoProgramadoCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatCatalogoVehiculo>
				if (CanDeepSave(entity.PatCatalogoVehiculoCollection, "List<PatCatalogoVehiculo>|PatCatalogoVehiculoCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatCatalogoVehiculo child in entity.PatCatalogoVehiculoCollection)
					{
						if(child.IdGrupoCatalogoSource != null)
						{
							child.IdGrupoCatalogo = child.IdGrupoCatalogoSource.IdGrupoCatalogo;
						}
						else
						{
							child.IdGrupoCatalogo = entity.IdGrupoCatalogo;
						}

					}

					if (entity.PatCatalogoVehiculoCollection.Count > 0 || entity.PatCatalogoVehiculoCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatCatalogoVehiculoProvider.Save(transactionManager, entity.PatCatalogoVehiculoCollection);
						
						deepHandles.Add("PatCatalogoVehiculoCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatCatalogoVehiculo >) DataRepository.PatCatalogoVehiculoProvider.DeepSave,
							new object[] { transactionManager, entity.PatCatalogoVehiculoCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region PatGrupoCatalogoChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>PAT.Entities.PatGrupoCatalogo</c>
	///</summary>
	public enum PatGrupoCatalogoChildEntityTypes
	{

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as OneToMany for PatKitCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatKit>))]
		PatKitCollection,

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as ManyToMany for PatTemparioCollection_From_PatTiempoTaller
		///</summary>
		[ChildEntityType(typeof(TList<PatTempario>))]
		IdOperacionPatTemparioCollection_From_PatTiempoTaller,

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as OneToMany for PatTiempoTallerCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatTiempoTaller>))]
		PatTiempoTallerCollection,

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as OneToMany for PatItemGrupoCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatItemGrupo>))]
		PatItemGrupoCollection,

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as ManyToMany for PatItemInventarioCollection_From_PatItemGrupo
		///</summary>
		[ChildEntityType(typeof(TList<PatItemInventario>))]
		IdItemInventarioPatItemInventarioCollection_From_PatItemGrupo,

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as ManyToMany for PatKitCollection_From_PatMantenimientoProgramado
		///</summary>
		[ChildEntityType(typeof(TList<PatKit>))]
		IdKitPatKitCollection_From_PatMantenimientoProgramado,

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as OneToMany for PatMantenimientoProgramadoCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatMantenimientoProgramado>))]
		PatMantenimientoProgramadoCollection,

		///<summary>
		/// Collection of <c>PatGrupoCatalogo</c> as OneToMany for PatCatalogoVehiculoCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatCatalogoVehiculo>))]
		PatCatalogoVehiculoCollection,
	}
	
	#endregion PatGrupoCatalogoChildEntityTypes
	
	#region PatGrupoCatalogoFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;PatGrupoCatalogoColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatGrupoCatalogo"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatGrupoCatalogoFilterBuilder : SqlFilterBuilder<PatGrupoCatalogoColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatGrupoCatalogoFilterBuilder class.
		/// </summary>
		public PatGrupoCatalogoFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatGrupoCatalogoFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatGrupoCatalogoFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatGrupoCatalogoFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatGrupoCatalogoFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatGrupoCatalogoFilterBuilder
	
	#region PatGrupoCatalogoParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;PatGrupoCatalogoColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatGrupoCatalogo"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatGrupoCatalogoParameterBuilder : ParameterizedSqlFilterBuilder<PatGrupoCatalogoColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatGrupoCatalogoParameterBuilder class.
		/// </summary>
		public PatGrupoCatalogoParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatGrupoCatalogoParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatGrupoCatalogoParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatGrupoCatalogoParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatGrupoCatalogoParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatGrupoCatalogoParameterBuilder
	
	#region PatGrupoCatalogoSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;PatGrupoCatalogoColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatGrupoCatalogo"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class PatGrupoCatalogoSortBuilder : SqlSortBuilder<PatGrupoCatalogoColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatGrupoCatalogoSqlSortBuilder class.
		/// </summary>
		public PatGrupoCatalogoSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion PatGrupoCatalogoSortBuilder
	
} // end namespace
